package 笔试真题;

import java.util.Scanner;
// 111111111
public class ShunFeng1 {
    static boolean[] booleans = new boolean[111111115];
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int ans =0;
        booleans[0] = true;
        booleans[11] = true;
        booleans[111] = true;
        booleans[1111] = true;
        booleans[11111] = true;
        booleans[111111] = true;
        booleans[1111111] = true;
        booleans[11111111] = true;
        booleans[111111111] = true;
        for (int i = 20; i < booleans.length; i++) {
            booleans[i] = booleans[i - 11] || i >= 111 && booleans[i - 111] || i >= 1111 && booleans[i - 1111] || i >= 11111 && booleans[i - 11111] || i >= 111111 && booleans[i - 111111] || i >= 1111111 && booleans[i - 1111111] || i >= 11111111 && booleans[i - 11111111] || i >= 111111111 && booleans[i - 111111111];
        }
        while (n-->0){
            int m = scanner.nextInt();
            if(m<= 111111115 && booleans[m]){
                ans ++;
            }else {
                if(deal(m)){
                    ans++;
                };
            }
        }
        System.out.println(ans);
    }

    private static boolean deal(int m) {
        if(m<111111115) return booleans[m];
        for (int i = 20; i < 111111115; i++) {
            if(booleans[i]){
                if(deal(m-i)){
                    return true;
                }
            }
        }
        return false;
    }
}
